<?php

namespace App\Http\Model\CoolNumberShoppingMall;

use App\Http\Model\Base;

/**
 * 靓号商城-商品标签
 *
 * Created on 2021/12/6 13:59
 * @Author <yuxiang.zhu@asiainnovations.net>
 */
class GoodsTag extends Base
{
    /**
     * 表名字
     *
     * @var string
     */
    protected $table = 'cool_number_tag';

    /**
     * 指示模型是否自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = true;

    /**
     * 模型日期列的存储格式。
     *
     * @var string
     */
    protected $dateFormat = 'U';

    /**
     * 可以被批量赋值的属性。
     *
     * @var array
     */
    protected $fillable = ['id', 'tag_name', 'tag_image', 'created_at', 'updated_at'];

    /**
     * @param array $attributes
     */
    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    /**
     * Created at 2021/12/6 18:11
     * @Author <yuxiang.zhu@asiainnovations.net>
     * @param array $tagIds
     * @return array
     */
    public function getTagsByIds(array $tagIds): array
    {
        return self::query()->select(['id', 'tag_name', 'tag_image'])->whereIn('id', $tagIds)->get()->toArray();
    }
}